/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlador;

import Facade.QuemaFacade;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author szuniga
 */
public class MantenedorQuemaAction extends DispatchAction {
    
    /* forward name="success" path="" */
    private final static String REGISTRAR = "registrar";
    private final static String CONSULTAR = "consultar";
    private final static String INICIO = "inicio";

    
    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction1,
     * where "method" is the value specified in <action> element : 
     * ( <action parameter="method" .../> )
     */
    public ActionForward registrar(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        QuemaFacade fcdQuema = new QuemaFacade();
        Vector resultado = fcdQuema.cargarRutQuema();

        request.setAttribute("rutVoluntarios", resultado);
        return mapping.findForward(REGISTRAR);
    }

    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction2,
     * where "method" is the value specified in <action> element : 
     * ( <action parameter="method" .../> )
     */
    public ActionForward consultar(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
         QuemaFacade fcdQuema = new QuemaFacade();

        Vector resultado = fcdQuema.listarQuemas();

        request.setAttribute("listaQuemas", resultado);
        return mapping.findForward(CONSULTAR);
    }

     public ActionForward inicio(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward(INICIO);
    }
}